<?php

namespace App\Models\Wanggui;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class CustomerDepartmentClueRecordModel extends BaseModel
{
    use HasFactory;

    protected $table = 'customer_department_clue_record';

    protected $fillable = [
        'taskId',
        'wgNumber',
        'followUpId',
        'status',
        'preHaving',
        'followUpTime',
        'content',
        'berthCount',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedByUid',
    ];

    /**
     * 线索状态
     */
    const STATUS_FOLLOWING_UP = 0;
    const STATUS_VOIDED       = 1;
    const STATUS_COMPLETE     = 2;
    const STATUS_OVERDUE      = 3;

    const STATUS_MAPPING = [
        self::STATUS_FOLLOWING_UP => '跟进中',
        self::STATUS_VOIDED       => '已作废',
        self::STATUS_COMPLETE     => '已完成',
        self::STATUS_OVERDUE      => '已过期',
    ];

    public function followUpRel(): HasMany
    {
        return $this->hasMany(CustomerDepartmentFollowUpRecordModel::class, 'clueId', 'id');
    }


    /**
     * 关联任务
     * @return HasOne
     */
    public function taskRel(): HasOne
    {
        return $this->hasOne(CustomerDepartmentTaskModel::class, 'id', 'taskId');
    }
}
